<%@ include file="/WEB-INF/jsp/includes.jsp" %>
<%@ include file="/WEB-INF/jsp/header.jsp" %>

<title><fmt:message key="uncaughtException.error"/></title>
</head>

<body>
<h2>Patchwork OSGi War Bundle Internal error</h2>
<p/>
<textarea readonly="readonly" name="trace" cols="128" rows="40" wrap="off">
    <%
        try {
            // The Servlet spec guarantees this attribute will be available
            Throwable exception = (Throwable) request.getAttribute("javax.servlet.error.exception");

            if (exception != null) {
                if (exception instanceof ServletException) {
                    // It's a ServletException: we should extract the root cause
                    ServletException sex = (ServletException) exception;
                    Throwable rootCause = sex.getRootCause();
                    if (rootCause == null)
                        rootCause = sex;
                    out.println("** Root cause is: " + rootCause.getMessage());
                    rootCause.printStackTrace(new java.io.PrintWriter(out));
                } else {
                    // It's not a ServletException, so we'll just show it
                    exception.printStackTrace(new java.io.PrintWriter(out));
                }
            } else {
                out.println("No error information available");
            }

            // Display cookies
            out.println("\nCookies:\n");
            if (request.getCookies() != null) {
                for (Cookie currentCookie : request.getCookies()) {
                    out.println(currentCookie.getName() + "=[" + currentCookie.getValue() + "]");
                }
            }

        } catch (Exception ex) {
            ex.printStackTrace(new java.io.PrintWriter(out));
        }
    %>
</textarea>
<p/>
</body>
</html>
